package Service;

import java.util.List;

import Dao.ExperimentDao;
import Dao.ExperimentDaoImpl;
import Entity.Experiment;

public class ExperimentService {
	public static ExperimentDaoImpl dao = null;

    public ExperimentService(){dao = new ExperimentDao();}

    public List<Experiment> findAllExperiment(){
        return dao.findAllExperiment();
    }
    public Experiment findExperimentById(int eid){
        return dao.findById(eid);
    }
    public boolean updateExperiment(Experiment experiment){
    	return dao.updateExperiment(experiment);
    }
    public boolean addExperiment(Experiment experiment){
    	return dao.addExperiment(experiment);
    }
    public boolean deleteExperiment(int id){
    	Experiment e=new Experiment();
    	e.setId(id);
    	return dao.deleteExperiment(e);
    }
    public static void main(String[] args) {
        ExperimentService ss = new ExperimentService();
//        for(int i=1;i<=4;i++)
//        ss.deleteExperiment(i);
//        ss.deleteExperiment(8);
//        for(int i=10;i<=13;i++)
//            ss.deleteExperiment(i);
//        ss.deleteExperiment(16);
        List<Experiment> allExperiment = ss.findAllExperiment();
        for (Experiment e:allExperiment){
  //      	e.setTe_name("周郭");
 //       	ss.updateExperiment(e);
        	if(e.getId()==9){
        		e.setName("组原实验");
        		ss.updateExperiment(e);
        	}
            System.out.println("id"+e.getId()+"   name"+e.getName());
        }
    }
}
